// The form contains fields for many pagiantion optiosn so you can 
// quickly see the resuluts of the different options.
// This function creates an option object for the pagination function.
// This will be be unnecessary in your application where you just set
// the options once.
$(function() {
	var items_on_page = 20;
        var pages_step = 5;

        get_data(1, 20);
        $.ajax({
                type: "POST",
                url: "/stores_total",
                data: {
                type: "get"},
                success: function(total)
                {
                        $("#paging_comments").jpaging({
                                all_items_num: total,
                                callback: get_data,
                                items_on_page: items_on_page,
                                pages_step: pages_step
                        });
                }
        });

        function get_data(start_index, end_index){
                start_index = start_index - 1;
                end_index = end_index - 1;
                $.ajax({
                        type: "POST",
                        url: "/stores_paging",
                        data: {start_index: start_index,
                        end_index: end_index,
                        type: "get"},
                        success: function(html)
                        {
                                $("#demo_tbl_comments").html(html);
				$.prettyDate.now = function() {
				return new Date();
				}
                                $("a").prettyDate();

                        }
                });
        }
});
